from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.response import Response
from app.models import StuModel

# Create your views here.

class StuView(APIView):
    def get(self,request):
        stus = StuModel.objects.all()
        stu_list = []
        for stu in stus:
            stu_list.append(
                {
                    'id':stu.id,
                    'name':stu.name,
                    'age':stu.age,
                    'score':stu.score
                }
            )
        return Response({'msg':'ok','data':stu_list})